package shop.yaojianfeng.springlearning.section8.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import shop.yaojianfeng.springlearning.section8.entity.RestEmployee;

/**
 * @author yaojianfeng
 */
@RestController
@RequestMapping("/rest")
public class RestWebController {

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/web/{eid}")
    public ResponseEntity<RestEmployee> queryWeb(@PathVariable("eid") String eid) {
        //模拟一次HTTP请求
        return restTemplate.getForEntity("http://localhost:8080/employee/{eid}", RestEmployee.class, eid);
    }
}
